using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


/// <summary>
/// The CategoryTypeCodeTableManager class is responsible for managing BO.CategoryTypeCodeTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class CategoryTypeCodeTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all CategoryTypeCodeTable objects in the database.
/// </summary>
/// <returns>A list with all CategoryTypeCodeTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static CategoryTypeCodeTableList GetList(){
return CategoryTypeCodeTableDB.GetList();
}

/// <summary>
/// Gets a single CategoryTypeCodeTable from the database without its data.
/// </summary>
/// <param name="categoryTypeCode">The CategoryTypeCode of the CategoryTypeCodeTable in the database.</param>
/// <returns>A CategoryTypeCodeTable object when the CategoryTypeCode exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static CategoryTypeCodeTable GetItem(Int16 categoryTypeCode)
{
return GetItem(categoryTypeCode, false);
}

/// <summary>
/// Gets a single CategoryTypeCodeTable from the database.
/// </summary>
/// <param name="categoryTypeCode">The CategoryTypeCode of the CategoryTypeCodeTable in the database.</param>
/// <param name="getCategoryTypeCodeTableRecords">Determines whether to load all associated CategoryTypeCodeTable records as well.</param>
/// <returns>
/// A CategoryTypeCodeTable object when the CategoryTypeCode exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static CategoryTypeCodeTable GetItem(Int16 categoryTypeCode, bool getCategoryTypeCodeTableRecords)
{
CategoryTypeCodeTable myCategoryTypeCodeTable = CategoryTypeCodeTableDB.GetItem(categoryTypeCode);
return myCategoryTypeCodeTable;
}

/// <summary>
/// Saves a CategoryTypeCodeTable in the database.
/// </summary>
/// <param name="myCategoryTypeCodeTable">The CategoryTypeCodeTable instance to save.</param>
/// <returns>The new CategoryTypeCode if the CategoryTypeCodeTable is new in the database or the existing CategoryTypeCode when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static Int16 Save(CategoryTypeCodeTable myCategoryTypeCodeTable)
{
using (TransactionScope myTransactionScope = new TransactionScope()){
    Int16 categoryTypeCodeTableCategoryTypeCode = CategoryTypeCodeTableDB.Save(myCategoryTypeCodeTable);

//  Assign the CategoryTypeCodeTable its new (or existing CategoryTypeCode).
myCategoryTypeCodeTable.CategoryTypeCode = categoryTypeCodeTableCategoryTypeCode;

myTransactionScope.Complete();

return categoryTypeCodeTableCategoryTypeCode;
}
}

/// <summary>
/// Deletes a CategoryTypeCodeTable from the database.
/// </summary>
/// <param name="myCategoryTypeCodeTable">The CategoryTypeCodeTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(CategoryTypeCodeTable myCategoryTypeCodeTable){
return CategoryTypeCodeTableDB.Delete(myCategoryTypeCodeTable.CategoryTypeCode);
}

#endregion

}

